<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    class Person {
      //  1、类中的构造函数
      // 当我们用new关键字调用一个Person类时,默认调用clas中的constructor方法
      constructor(name, age) {
        this.name = name;
        this.age = age;
      }
      // 实例方法
      // 本质上是放在Person.prototype
      running(){
        console.log(this.name+'running~')
      }
      eating(){
        console.log(this.name+'eating~')
      }
    }
    var p1 = new Person('why',18)
    console.log(p1.name,p1.age)
    p1.running()
  </script>
</body>

</html>